<?php

declare(strict_types=1);

namespace App\Service;

use App\Models\AgentRewardRuleSettings;

class AgentRewardRuleSettingsService
{
    /***
     * 获取奖励设置
     * @param null $type
     * @return array|mixed
     */
    public function rewardSetting($type = null)
    {
        $settings = AgentRewardRuleSettings::query()->get()->toArray();

        if ($type !== null) {
            return array_filter($settings, fn($setting) => $type === $setting['type']);
        }

        return $settings;
    }
}
